<!DOCTYPE html>
<html lang="zh-Hans-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>watch选项:状态监听</title>
    <script src="../vue.js"></script>
</head>
<body>
<h2>【例5】watch选项:状态监听</h2>
<hr>
<div id="app">
    <label>所在城市：<input type="text" v-model="cityName"></label>
</div>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            cityName: '上海'
        },
        watch: {
            cityName(newName, oldName) {
                console.log(newName, oldName)
            }
        }
    })
</script>
<hr>
<p><a href="index.html">返回章节目录</a>
    <script>document.write(document.lastModified); </script>
</p>
</body>
</html>
